<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableOrderdatas extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orderdatas', function (Blueprint $table) {
            $table->increments('id')->comment('明细编号');
            $table->unsignedInteger('order_id')->default('0')->comment('orders外键.订单编号');
            $table->unsignedInteger('cate_pid')->default('0')->comment('categorys外键.商品编号');
            $table->string('pname')->default('')->comment('商品名称');
            $table->string('plogo')->default('')->comment('商品Logo');
            $table->decimal('pmoney',10,1)->default('0.0')->comment('商品价格');
            $table->unsignedSmallInteger('num')->default('0')->comment('购买数量');
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
            $table->foreign('cate_pid')->references('pid')->on('categorys');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('orderdatas');
    }
}
